from Xlib.display import Display


class SetGeometry():
    """ Setting a new app location. mode = [0-8]: default mode = 4. """
    def __init__(self):
        super(SetGeometry, self).__init__()
        self.rezolution = Display().screen().root.get_geometry()
        self.size = (394, 248)

    def get(self):
        """ Getting current rezolution screen. """
        return self.rezolution.width, self.rezolution.height

    def getSize(self):
        width, height = self.get()
        return ((25, 35, *self.size),
            (width//2-self.size[0]//2, 35, *self.size),
            (width-self.size[0]-25, 35, *self.size),
            (25, height//2-self.size[1]//2, *self.size),
            (width//2-self.size[0]//2, height//2-self.size[1]//2, *self.size),
            (width-self.size[0]-25, height//2-self.size[1]//2, *self.size),
            (25, height-self.size[1]-35, *self.size),
            (width//2-self.size[0]//2, height-self.size[1]-55, *self.size),
            (width-self.size[0]-25, height-self.size[1]-35, *self.size))

    def set(self, mode=4):
        """ Calculation of data to determinate the location of the app. """
        return self.getSize()[mode]
